package com.aqie.easy.bitOperation;

import java.util.ArrayList;
import java.util.List;

/**
 * @Function: 784. 字母大小写全排列
 * @Author: aqie
 * @Date: 2019/7/2 21:32
 */
public class LetterCasePermutation {
    public static List<String> letterCasePermutation(String S) {
        int l = S.length();
        double n = Math.pow(2, l);
        List<String> ans = new ArrayList<>();
        if (l == 0) return ans;
        for (int i = 0; i < n; i++){
            StringBuilder tmp = new StringBuilder();
            for (int j = 0; j < l; j ++){
                if (((int)Math.pow(2,j) & i)  == 0){
                    tmp.append(String.valueOf(S.charAt(j)).toLowerCase());
                }else{
                    tmp.append(String.valueOf(S.charAt(j)).toUpperCase());
                }
            }
            if (!ans.contains(tmp.toString())){
                ans.add(tmp.toString());
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        String s = "a1b2";
        System.out.println(letterCasePermutation(s));
    }
}
